﻿using System;
using System.Drawing;

namespace ExFlash.Records
{
    public class LineStyleRecord : ISwfSerializable
    {
        protected ShapeType ShapeType;

        public ushort Width
        {
            get;
            protected set;
        }

        public RGBRecord Color
        {
            get;
            protected set;
        }

        public LineStyleRecord(ShapeType type)
        {
            ShapeType = type;
        }

        public virtual Pen GetPen()
        {
            return new Pen(Color.GetColor(), Width);
        }

        #region ISwfSerializable Members

        public virtual void SwfDeserialize(BinaryBitReader reader)
        {
            Width = reader.ReadUInt16();

            if (ShapeType == ShapeType.Shape1 || ShapeType == ShapeType.Shape2)
            {
                Color = new RGBRecord();
            }
            else
            {
                Color = new RGBARecord();
            }

            Color.SwfDeserialize(reader);
        }

        public virtual void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
